improvement(copilot): make copilot_messages the sole transcript store, remove JSONB dual-write#4826
improvement(copilot): make copilot_messages the sole transcript store, remove JSONB dual-write#4826waleedlatif1 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Persistence behavior changes in several places: user and assistant turns are appended via Reads and copies that still touched JSONB now load from the normalized table: Dropping the Reviewed by Cursor Bugbot for commit c6d7852. Configure here. |
Greptile SummaryThis PR removes the dual-write pattern for copilot chat transcripts, making
Confidence Score: 4/5Safe to merge with one unresolved defect in the background inbox path where message loss can occur silently. The core interactive-chat path is correctly hardened: the assistant turn is now persisted atomically inside the transaction in terminal-state.ts, and messages-store.ts throws on failure everywhere it's wired up. The gap is in executor.ts's persistChatMessages, the background inbox path: a try/catch swallows any throw from appendCopilotChatMessages, and the db.update(updatedAt) commits before the append runs, so a failure there leaves updatedAt bumped with no messages written. This is the same defect called out in the previous review round and is still unaddressed in this diff. apps/sim/lib/mothership/inbox/executor.ts — persistChatMessages still swallows append failures and lacks a transaction wrapping the two writes. Important Files Changed
Reviews (3): Last reviewed commit: "improvement(copilot): make copilot_messa..." | Re-trigger Greptile |
f1a0d4c to
6d718cf
Compare
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6d718cf. Configure here.
…, remove JSONB dual-write Stop writing/reading the legacy copilot_chats.messages JSONB column now that reads are cut over to copilot_messages. Make appendCopilotChatMessages the primary write (throws on failure instead of swallowing), repoint peripheral readers (workspace VFS, chat cleanup, data drains, fork, superuser import) to copilot_messages, and persist the assistant turn inside finalizeAssistantTurn's transaction so it commits atomically with the stream-marker clear. The column itself is dropped in a follow-up migration after this bakes.
6d718cf to
c6d7852
Compare
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c6d7852. Configure here.
Summary
copilot_chats.messagesJSONB column now that all transcript reads are cut over to the normalizedcopilot_messagestable.appendCopilotChatMessages/replaceCopilotChatMessagesthe primary store and throw on failure (previously best-effort/swallowed — a swallowed write now means permanent message loss).finalizeAssistantTurn's transaction so it commits atomically with the stream-marker clear (closes the "marker cleared but message lost" window).copilot_messages: workspace VFS task materialization, chat-cleanup file collection, data-drains export (batched per-page assembly, no N+1), chat fork, and superuser workflow import.messages-dual-write.ts→messages-store.ts(no longer "dual"); dropped the now-impossible user-existence dedup check infinalizeAssistantTurn.ALTER TABLE copilot_chats DROP COLUMN messages) + reconcile-script removal are intentionally deferred to a follow-up migration PR so this can bake with a safe rollback.Type of Change
Testing
lib/copilot/chat,lib/cleanup,app/api/copilot/chat,app/api/mothership.tsc --noEmitclean (0 errors), biome clean,check:api-validationpasses.copilot_messagesare byte-identical and correctly ordered; the JSONB column is no longer written.Checklist